package kburndown.client.app.utils
{
	public class DateHelper
	{
		public static var OneDay: Number = (1000 * 60 * 60 * 24);
		public static var OneWeek: Number = OneDay * 7;
		
		
		private static var _today: Date;
		public static function setToday(v: Date): void
		{
			_today = v;
		}
		
		public static function getToday(): Date
		{
			if(_today)
				return new Date(_today.time);
			else
			{
				var nowDate: Date = new Date();
				return new Date(nowDate.fullYear, nowDate.month, nowDate.date,
					8);
			}
		}
		
		public static function getNextMonday(): Date
		{
			var nowDate: Date = new Date();
			var newDate: Date = new Date(nowDate.time / OneWeek * (OneWeek + 1) + OneDay);
			newDate = new Date(newDate.fullYear, newDate.month, newDate.date,
				8);
			return newDate;
		}
		
		public static function getDayCountBetween(beginDate: Date, endDate: Date): int
		{
			return (endDate.time - beginDate.time) / OneDay;
		}
		
		/**
		 * @param index
		 *		返回几天前的一个时间 
		 */		
		public static function getDateBefor(index: int): Date
		{
			return new Date(getToday().time - index * OneDay);
		}
	}
}